<?php
namespace Api\Controller;
use Think\Controller;

class NoticeController extends BaseController {

   private $m = NULL;
   private $md = NULL;
   private $navName = '订单管理';


   public function _initialize(){
   		parent::_initialize();
		$this->m = M('shop_notice');
		
		
		
   }
 /**  会通知 liuq
 *
 */	
  
   
public  function  slist(){
    
            $page  = I('page');//页码
            $now_time = time();
            $data = $this->m->where('end_time > "'.$now_time.'" AND  check_status = 2')->page( $page.',10')->select();
            $count_num = $this->m->where('end_time > "'.$now_time.'" AND  check_status = 2')->order('add_time desc')->count();
            foreach( $data as $key => $item ){

               $data1[$key]['id'] = $item['id'];
               $data1[$key]['mid'] = $item['mid'];
               $data1[$key]['shop_name'] = M('shop')->where('mid="'.$item['mid'].'"')->getField('shop_name');
               $data1[$key]['title'] = $item['title'];
               $data1[$key]['news'] = $item['news'];        
               $data1[$key]['not_pic'] = $item['not_pic']?__VUPLOAD__.'not_pic/'.$item['not_pic']:"";
            }


               returnApiData3('0','成功',$data1, $data2,$data3,$count_num);exit;	     

        }
  


   public  function  shop_detail(){
                   $mid = I('mid');
                   $shop_id = M('shop')->where('mid="'.$mid.'"')->getField('id');
                   $shop_level_three = M('shop')->where('mid="'.$mid.'"')->getField('shop_level_three');
                   $dataInfo = M('shop_detail')->where('s_id="'.$shop_id.'"')->find();
                   $data['mid'] = $mid;
                   $data['shop_toppics']  =  $dataInfo['shop_toppics']?__VUPLOAD__.'shop_toppics/'.$dataInfo['shop_toppics']:"";
                   $data['shop_heapic']  =  $dataInfo['shop_heapic']?__VUPLOAD__.'shop_heapic/'.$dataInfo['shop_heapic']:"";
                   $data['shop_name'] = M('shop')->where('mid="'.$mid.'"')->getField('shop_name');
                   $data['shop_intro'] = M('shop')->where('mid="'.$mid.'"')->getField('shop_intro');    
                   $data['address'] = M('shop_detail')->where('s_id="'.$shop_id.'"')->getField('address'); 
                   $data['class_name'] = M('shop_product_class')->where('id="'.$shop_level_three.'"')->getField('class_name');
                   $data['shop_intropics'] = $dataInfo['shop_intropics'];  
                   $data['per_consumption'] = $dataInfo['per_consumption'];   
                   $data['telephone'] = M('shop_detail')->where('s_id="'.$shop_id.'"')->getField('telephone');  
                  // $data['class_name'] = M('shop_product_class')->where('id="'.$dataInfo['shop_level_three'].'"')->getField('class_name');
                       
                   $attitude = M('shop_evaluate')->where('mid="'.$mid.'"')->sum('attitude_star'); 
                   $speed = M('shop_evaluate')->where('mid="'.$mid.'"')->sum('speed_star'); 
                   $taste = M('shop_evaluate')->where('mid="'.$mid.'"')->sum('taste_star'); 
                   $evaluate_times = M('shop_evaluate')->where('mid="'.$mid.'"')->count();
                   $comment_star = round(( $attitude  + $speed + $taste )/( $evaluate_times*3 ));  
                   $data['comment_star_num'] = $comment_star;
                    
                   if(  $comment_star == 1 ){
                      $data['comment_star_value'] = __VUPLOAD__.'evaluate/'."1star.png";
                   }elseif(   $comment_star == 2  ){
                      $data['comment_star_value'] = __VUPLOAD__.'evaluate/'."2star.png";
                   }elseif(   $comment_star == 3  ){
                      $data['comment_star_value'] = __VUPLOAD__.'evaluate/'."3star.png";
                   }elseif(   $comment_star == 4  ){
                      $data['comment_star_value'] = __VUPLOAD__.'evaluate/'."4star.png";
                   }elseif(   $comment_star == 5  ){
                      $data['comment_star_value'] = __VUPLOAD__.'evaluate/'."5star.png";
                   }else{
                      $data['comment_star_value'] = __VUPLOAD__.'evaluate/'."6star.png";
                   }
                   
//                   
//                   
//                  $mid_movie = M('shop_movie')->where('mid="'.$mid.'"')->order('add_time  desc')->select();
//                  foreach ( $mid_movie  as $key => $value){
//                      $data2[$key]['mov_name'] = $value['mov_name'];
//                      $data2[$key]['mov_pic'] = $value['mov_pic']?__VUPLOAD__.'mov_pic/'.$value['mov_pic']:""; //电影头像
//                   }
                   
                $page  = I('page');//页码
             
                $data5 = M('shop_activity')->where(' mid="'.$mid.'"')->page( $page.',10')->select();
                $count_num = M('shop_activity')->where(' mid="'.$mid.'"')->order('add_time desc')->count();
                
                foreach( $data5 as $key => $item ){
                   $data1[$key]['id'] = $item['id'];
                   $data1[$key]['title'] = $item['title'];
                   $data1[$key]['description'] = $item['description'];
                   $data1[$key]['ac_pic'] = $item['not_pic']?__VUPLOAD__.'ac_pic/'.$item['ac_pic']:"";
                   
                }
     
                  returnApiData3('0','成功',$data, $data1,$data3,$count_num);exit;	     
           }
                  
                

}